﻿@page "/PlayAudio"
@attribute [TabItemOption(Text = "播放语音/文本转语音")]

<a href="https://www.nuget.org/packages/BootstrapBlazor.OCR#readme-body-tab"><h4>播放语音 PlayAudio</h4></a>
<hr />
<a href="https://github.com/densen2014/Densen.Extensions/blob/master/Demo/DemoShared/Pages/PlayAudioPage.razor"><h5>页面源码</h5></a>

<PlayAudio @ref="PlayAudio" />

<Tab IsLazyLoadTabItem="true">
    <TabItem Text="常规">
        <div class="row g-3">
            <div class="col-12">
                <BootstrapInputGroup>
                    <BootstrapInput IsAutoFocus ShowLabel="true" TValue="string" PlaceHolder="@PlaceHolderText" OnEnterAsync="OnEnterAsync" OnEscAsync="OnEscAsync" @bind-Value="InputText" />
                    <Button Text="转换" OnClick="OnPlay" Icon="fa-fw fa-solid fa-play" IsAsync/>
                </BootstrapInputGroup>
            </div>
            <div class="col-6">
                <Select Color="Color.Primary" Items="ItemsVoiceName" @bind-Value="@SelectedVoiceName" ShowLabel="true" />
            </div>
            <div class="col-6">
                <Select Color="Color.Primary" Items="ItemsVoiceStyle" @bind-Value="@SelectedVoiceStyle" ShowLabel="true" />
            </div>
            <div class="col-12">
                <code>
                    &lt;PlayAudio @@ref="PlayAudio" /&gt;<br />
                    PlayAudio PlayAudio;<br />
                    await PlayAudio.Play(InputText, SelectedVoice, SelectedStyle)<br />
                </code>
            </div>
        </div>
    </TabItem>
    <TabItem Text="简易">
        <code>&lt;PlayAudio TextOrSSML="你好,Blazor!" /&gt;</code>
        <PlayAudio TextOrSSML="你好,Blazor!" />
    </TabItem>
    <TabItem Text="示例">
        <div class="row g-3">
            <div class="col-12">
                <BootstrapInputGroup>
                    <Button Text="测试" OnClick="OnPlaySSML" Icon="fa-fw fa-solid fa-play" IsAsync />
                    <Select Color="Color.Primary" Items="ItemsSSML" @bind-Value="@ItemSSML" ShowLabel="true" />
                </BootstrapInputGroup>
            </div>
            <div class="col-12">
                <Textarea @bind-Value="ItemSSML" rows="20" />
            </div>
            <div class="col-12">
                <code>
                    &lt;PlayAudio @@ref="PlayAudio" /&gt;<br />
                    PlayAudio PlayAudio;<br />
                    await PlayAudio.Play(ItemSSML)<br />
                </code>
            </div>
        </div>
    </TabItem>
</Tab>


@if (!string.IsNullOrEmpty(ErrorMessage))
{
    <p>@ErrorMessage</p>
}

